﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.IBLL;
using HZ.Supervise.Model;
using HZ.Supervise.Model.Query;

namespace HZ.Supervise.Web.Secondphase
{
    public partial class SubscribeMessage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void sortbind()
        {

        }
        public static string getArea()
        {
            HZ.Supervise.Model.User user = CurrentAccount.GetUser();
            string AreaID = user.Org.Area.AreaID;
            return AreaID;
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwMessage_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //GridViewRow r = gvwMessage.Rows[e.RowIndex];
            //Model.Sort sort = new HZ.HC.Model.Sort();

            //sort.SortId = Convert.ToString(gvwMessage.DataKeys[e.RowIndex].Value);
            //sort.SortName = ((TextBox)gvwMessage.Rows[e.RowIndex].FindControl("txtsortname")).Text.Trim();
            //if (!string.IsNullOrEmpty(((TextBox)gvwMessage.Rows[e.RowIndex].FindControl("txtsortname")).Text.Trim()))
            //{
            //    sort.SortName = ((TextBox)gvwMessage.Rows[e.RowIndex].FindControl("txtsortname")).Text.Trim();
            //    IList<HZ.HC.Model.Sort> list = HZ.HC.BLL.BLLFactory.BLL_Sort().GetSortList(" and SortName = '" + sort.SortName + "'");
            //    if (list.Count > 0)
            //    {
            //        HZ.Web.WebUtil.Alert("您输入的类别名称已经存在！", this);
            //        return;
            //    }
            //}
            //else
            //{
            //    HZ.Web.WebUtil.Alert("类别名称不能为空！", this);
            //    ((TextBox)gvwMessage.Rows[e.RowIndex].FindControl("txtsortname")).Focus();
            //    return;
            //}
            //try
            //{
            //    int flag = HZ.HC.BLL.BLLFactory.BLL_Sort().UpdateSortName(sort);
            //    if (flag == 1)
            //    {
            //        HZ.HC.BLL.BLLFactory.BLL_Sort().UpdateOtherSortName(sort.SortId, sort.SortName);
            //        gvwMessage.EditIndex = -1;
            //        sortbind();
            //        Model.Log_Common.AddLog(new Model.Log_Common()
            //        {
            //            LogUserName = CurrentAccount.Account.UserName + "|" + CurrentAccount.Account.UserID,
            //            IPAddress = HZ.Fun.GetClientIP(),
            //            LogMessange = string.Format("中心端更新父类"),
            //            LogObject = Model.Log_Common.GetStringFromObject(sort),
            //            LogType = 2
            //        });

            //        HZ.Web.WebUtil.Alert("更新成功！", this);
            //    }

            //    else
            //    {
            //        HZ.Web.WebUtil.Alert("更新失败！", this);
            //    }
            //}
            //catch (Exception em)
            //{
            //    HZ.Web.WebUtil.Alert(em.Message, this);

            //}
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwMessage_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvwMessage.EditIndex = e.NewEditIndex;
            sortbind();
        }

        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwMessage_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvwMessage.EditIndex = -1;
            sortbind();

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            sortbind();
        }
    }
}
